package leetcode;

import java.util.*;

public class LeetCodeMain79 {
    public void nextPermutation(int[] nums) {
        int i= nums.length-2;
        while (i>=0&&nums[i]>=nums[i+1]){
            i--;
        }
        if (i>=0){
            int j=nums.length-1;
            while (j>=0&&nums[i]>=nums[j]){
                j--;
            }
            swap(nums,i,j);
        }
        reverse(nums,i+1);
    }

    public void swap(int[] nums, int i, int j) {
        int temp = nums[i];
        nums[i] = nums[j];
        nums[j] = temp;
    }
    public void reverse(int[] nums, int start) {
        int left = start, right = nums.length - 1;
        while (left < right) {
            swap(nums, left, right);
            left++;
            right--;
        }
    }
    public List<List<String>> groupAnagrams(String[] strs) {
        List<List<String>> list=new ArrayList<>();
        int length=strs.length;
        HashMap<String,List<String>> map=new HashMap<>();
        for (int i = 0; i < length; i++) {
            char[] ch=strs[i].toCharArray();
            Arrays.sort(ch);
            String str=new String(ch);

            if (map.containsKey(str)){
                List<String> list1=map.get(str);
                list1.add(strs[i]);
                map.put(str,list1);
            }else {
                List<String> list1=new ArrayList<>();
                list1.add(strs[i]);
                map.put(str,list1);
            }
        }
        for (Map.Entry<String,List<String>> set:map.entrySet()) {
            list.add(new ArrayList<>(set.getValue()));
        }
        return list;
    }
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        while (in.hasNext()){
            int num=in.nextInt();
            String[] arr=new String[num];
            for (int i = 0; i < num; i++) {
                arr[i]=in.next();
            }
            Arrays.sort(arr);
            boolean[] flag=new boolean[num];
            for (int i = 0; i < num-1; i++) {
                if (arr[i].equals(arr[i+1])||(arr[i+1].contains(arr[i])&&arr[i+1].charAt(arr[i].length())=='/')){
                    flag[i]=true;
                }
            }
            for (int i = 0; i < num; i++) {
                if (flag[i]){
                    System.out.println("mkdir -p "+arr[i]);
                }
            }
        }
    }
    public static void main1(String[] args) {
        Scanner in=new Scanner(System.in);
        while (in.hasNext()){
            int num=in.nextInt();
            in.nextLine();
            int max=0;
            Set<String> set=new HashSet<>();
            for (int i = 0; i < num; i++) {
                String string=in.nextLine();
                String[] arr=string.split(" ");
                if (arr[1].equals("connect")){
                    set.add(arr[0]);
                }else {
                    max=Math.max(set.size(),max);
                    set.remove(arr[0]);
                }
            }
            System.out.println(max);
        }
    }
    public void rotate(int[][] matrix) {
        int length=matrix.length;
        int[][] arr=new int[length][length];
        int x=0;
        for (int i = 0; i < length; i++) {
            int y=0;
            for (int j = length-1; j >=0; j--) {
                arr[x][y++]=matrix[j][i];
            }
            x++;
        }
        for (int i = 0; i < length; i++) {
            for (int j = 0; j < length; j++) {
                matrix[i][j]=arr[i][j];
            }
        }
    }
}
